#include<cstdio>//uncle-lu
#include<vector>
#include<cstring>
#include<algorithm>
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9') { f|=(ch=='-'); ch=getchar(); }
	while(ch<='9'&&ch>='0') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	x = f ? -x : x;
	return ;
}

std::vector<int>son[200];
bool visit[200];
int F[200][200];
int cnt[200];
int n, p;

void DFS(int x)
{
	cnt[x] = 1;
	for (int i = 0; i < (int)son[x].size(); i++) 
	{
		int v = son[x][i];
		DFS(v);
		cnt[x] += cnt[v];
		for (int j = cnt[x]; j >= 1; j--) 
			for (int k = 1; k <= j-1; k++) 
				F[x][j] = std::min(F[x][j], F[x][j-k] + F[v][k] -1);
	}
	return ;
}

int main()
{
	read(n);read(p);
	int x, y;
	for (int i = 1; i <= n-1; i++) 
	{
		read(x);read(y);
		son[x].push_back(y);
		visit[y] = true;
	}

	memset(F, 0x7f7f, sizeof(F));
	int root;
	for (int i = 1; i <= n; i++) 
	{
		if(!visit[i])root = i;
		F[i][1] = son[i].size() ;
	}

	DFS(root);

	int ans = F[root][p];
	for (int i = 1; i <= n; i++) 
		ans = std::min(ans, F[i][p] + 1);

	printf("%d", ans);
	return 0;
}
